package com.ruoyi.bearing.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bearing.domain.BearingLifeForecastResult;
import com.ruoyi.bearing.service.IBearingLifeForecastResultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 寿命预测结果Controller
 * 
 * @author ruoyi
 * @date 2025-02-08
 */
@RestController
@RequestMapping("/bearing/result")
public class        BearingLifeForecastResultController extends BaseController
{
    @Autowired
    private IBearingLifeForecastResultService bearingLifeForecastResultService;

    /**
     * 查询寿命预测结果列表
     */
    @PreAuthorize("@ss.hasPermi('bearing:result:list')")
    @GetMapping("/list")
    public TableDataInfo list(BearingLifeForecastResult bearingLifeForecastResult)
    {
        startPage();
        List<BearingLifeForecastResult> list = bearingLifeForecastResultService.selectBearingLifeForecastResultList(bearingLifeForecastResult);
        return getDataTable(list);
    }

    /**
     * 导出寿命预测结果列表
     */
    @PreAuthorize("@ss.hasPermi('bearing:result:export')")
    @Log(title = "寿命预测结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BearingLifeForecastResult bearingLifeForecastResult)
    {
        List<BearingLifeForecastResult> list = bearingLifeForecastResultService.selectBearingLifeForecastResultList(bearingLifeForecastResult);
        ExcelUtil<BearingLifeForecastResult> util = new ExcelUtil<BearingLifeForecastResult>(BearingLifeForecastResult.class);
        util.exportExcel(response, list, "寿命预测结果数据");
    }

    /**
     * 获取寿命预测结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('bearing:result:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bearingLifeForecastResultService.selectBearingLifeForecastResultById(id));
    }

    /**
     * 新增寿命预测结果
     */
    @PreAuthorize("@ss.hasPermi('bearing:result:add')")
    @Log(title = "寿命预测结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BearingLifeForecastResult bearingLifeForecastResult)
    {
        return toAjax(bearingLifeForecastResultService.insertBearingLifeForecastResult(bearingLifeForecastResult));
    }

    /**
     * 修改寿命预测结果
     */
    @PreAuthorize("@ss.hasPermi('bearing:result:edit')")
    @Log(title = "寿命预测结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BearingLifeForecastResult bearingLifeForecastResult)
    {
        return toAjax(bearingLifeForecastResultService.updateBearingLifeForecastResult(bearingLifeForecastResult));
    }

    /**
     * 删除寿命预测结果
     */
    @PreAuthorize("@ss.hasPermi('bearing:result:remove')")
    @Log(title = "寿命预测结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bearingLifeForecastResultService.deleteBearingLifeForecastResultByIds(ids));
    }
}
